import { getRequest } from '@/api/interceptor'
import { transSingerInfo, transAlbums, transMvs } from '@/api/artists/translate'

const REQUEST_URL = {
  artistDetail: '/artist/detail',
  singerLists: '/artist/list',
  singerInfo: '/artists',
  singerAlbums: '/artist/album',
  singerIntro: '/artist/desc',
  singerMvs: '/artist/mv',
  simiSingers: '/simi/artist',
  albumSongs: '/album'
}

export const getArtistDetail = (id: number) => {
  return getRequest(REQUEST_URL.artistDetail, { id })
}

export const getSingerLists = ({ type, area, initial, limit, offset }) => {
  return getRequest(REQUEST_URL.singerLists, { type, area, initial, limit, offset: offset * limit })
}

export const getSingerInfo = ({ id }) => {
  return getRequest(REQUEST_URL.singerInfo, { id }).then(transSingerInfo)
}

export const getAlbums = ({ id, limit, offset }) => {
  return getRequest(REQUEST_URL.singerAlbums, { id, limit, offset: offset * limit }).then(transAlbums)
}

export const getAlbumSongs = (id) => {
  return getRequest(REQUEST_URL.albumSongs, { id })
}

export const getSingerMvs = ({ id, limit, offset }) => {
  return getRequest(REQUEST_URL.singerMvs, { id, limit, offset: limit * offset }).then(transMvs)
}

export const getSingerDesc = (id) => {
  return getRequest(REQUEST_URL.singerIntro, { id })
}

export const getSimiSinger = (id) => {
  return getRequest(REQUEST_URL.simiSingers, { id })
}
